﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{

    Layout = null;
}

<script src="~/lib/layui/layui.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />

<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/js/js.cookie.js"></script>
<script src="~/js/moment.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>

<script src="//unpkg.com/layui@2.9.20/dist/layui.js"></script>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Demo</title>
    <!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
    <link href="//unpkg.com/layui@2.9.20/dist/css/layui.css" rel="stylesheet">
</head>
<body>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">工序编码</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="请输入" class="layui-input" style="width:200px" id="procedureCode" />
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-form" onclick="Automatic()">
                <input type="checkbox" name="CCC" title="自动生成|关闭自动生成" lay-skin="switch" class="GMon" value="1">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">工序名称</label>
            <div class="layui-input-inline">
                <input type="text" placeholder="请输入" class="layui-input" style="width:200px" id="processName" />
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">是否启用</label>
            <div class="layui-input-inline">
                <div class="layui-form" onclick="Automatics()">
                    <input type="checkbox" name="CCC" title="是|否" lay-skin="switch" onclick="" class="GMonss" value="1">
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">工序说明</label>
            <div class="layui-input-inline">
                <textarea name="" placeholder="多行文本框" class="layui-textarea" style="width:500px" id="processInstructions"></textarea>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <textarea name="" placeholder="多行文本框" class="layui-textarea" style="width:500px" id="descriptionToreMark"></textarea>
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">  
            <div class="layui-input-inline">
                <button type="button" class="layui-btn layui-btn-primary layui-btn-radius" onclick="Stach()">添加</button>
            </div>
        </div>
    </div>

</body>
</html>
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->



<script>



    var getisEnable = "";

    function Automatics() {


        var gh = $('.GMonss:checked').val()
        console.log(gh);

        if (gh == 1) {
            getisEnable = 0;
        }
        if (gh != 1) {
            getisEnable = 1;
        }
    }

    //自动生成
    function Automatic(){


        var gh = $('.GMon:checked').val()
        console.log(gh);

        if (gh==1) {
            var Encoding = "MG" + Math.random().toString().substring(2, 6);

            $("#procedureCode").val(Encoding)
        }
        if (gh!=1) {
            $("#procedureCode").val('');
        }
    }

        ///仓库添加

    function Stach() {

        var date = {

            processid: 0,
            procedureCode: $("#procedureCode").val(),
            processName: $("#processName").val(),
            isEnable: getisEnable,
            processInstructions: $("#processInstructions").val(),
            descriptionToreMark: $("#descriptionToreMark").val(),
        };

        console.log(date, '111111111')
        $.ajax({
            url: '@ViewBag.FoundationWrite'+ "/api/Jocker/processCreate",
            type:'post',
            data: JSON.stringify(date),
            dataType:"json",
            contentType: "application/json",
            success: res => {
                if (res.code > 0) {
                    alert("添加成功");
                    // location.href = "../Document/index";

                }
                else {

                }

            }

        })



    }











</script>


